/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Felipe Duarte
 */
@Entity
@Table(name = "medida_material")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MedidaMaterial.findAll", query = "SELECT m FROM MedidaMaterial m"),
    @NamedQuery(name = "MedidaMaterial.findByIdMedidaMaterial", query = "SELECT m FROM MedidaMaterial m WHERE m.idMedidaMaterial = :idMedidaMaterial"),
    @NamedQuery(name = "MedidaMaterial.findByNombreMedidaMaterial", query = "SELECT m FROM MedidaMaterial m WHERE m.nombreMedidaMaterial = :nombreMedidaMaterial")})
public class MedidaMaterial implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_MEDIDA_MATERIAL")
    private Integer idMedidaMaterial;
    @Size(max = 45)
    @Column(name = "NOMBRE_MEDIDA_MATERIAL")
    private String nombreMedidaMaterial;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "medidaMaterialIdMedidaMaterial")
    private List<MaterialConstruccion> materialConstruccionList;

    public MedidaMaterial() {
    }

    public MedidaMaterial(Integer idMedidaMaterial) {
        this.idMedidaMaterial = idMedidaMaterial;
    }

    public Integer getIdMedidaMaterial() {
        return idMedidaMaterial;
    }

    public void setIdMedidaMaterial(Integer idMedidaMaterial) {
        this.idMedidaMaterial = idMedidaMaterial;
    }

    public String getNombreMedidaMaterial() {
        return nombreMedidaMaterial;
    }

    public void setNombreMedidaMaterial(String nombreMedidaMaterial) {
        this.nombreMedidaMaterial = nombreMedidaMaterial;
    }

    @XmlTransient
    public List<MaterialConstruccion> getMaterialConstruccionList() {
        return materialConstruccionList;
    }

    public void setMaterialConstruccionList(List<MaterialConstruccion> materialConstruccionList) {
        this.materialConstruccionList = materialConstruccionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMedidaMaterial != null ? idMedidaMaterial.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MedidaMaterial)) {
            return false;
        }
        MedidaMaterial other = (MedidaMaterial) object;
        if ((this.idMedidaMaterial == null && other.idMedidaMaterial != null) || (this.idMedidaMaterial != null && !this.idMedidaMaterial.equals(other.idMedidaMaterial))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.MedidaMaterial[ idMedidaMaterial=" + idMedidaMaterial + " ]";
    }
    
}
